#!/bin/bash
# Kylin ISO自动挂载及Yum源配置脚本

# 步骤1：创建挂载目录
# umount /mnt/cdrom

# 步骤4：备份原有yum源并创建新配置
YUM_REPO_DIR="/etc/yum.repos.d"
mkdir -p $YUM_REPO_DIR/bak
mv $YUM_REPO_DIR/*.repo $YUM_REPO_DIR/bak/ 2>/dev/null

cat > $YUM_REPO_DIR/Kylin-base.repo <<EOF
###Kylin Linux Advanced Server 10 - os repo###

[V10-SP3-2403-os]
name = Kylin Linux Advanced Server 10 - Os
baseurl = http://10.225.128.17:9527/V10-SP3-2403-os/
gpgcheck = 0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1

[V10-SP3-2403-updates]
name = Kylin Linux Advanced Server 10 - Updates
baseurl = http://10.225.128.17:9527/V10-SP3-2403-updates/
gpgcheck = 0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1
EOF

# 步骤5：更新yum缓存
rm -rf /var/cache/yum/*
yum clean all
yum makecache

echo "脚本执行完成，请验证以下内容："
echo "1. 检查挂载状态: df -h | grep cdrom"
echo "2. 检查Yum源列表: yum repolist"
